package com.frejoys.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.frejoys.common.aop.Authority;
import com.frejoys.common.aop.Authorization;
import com.frejoys.common.constant.CommonConstant;
import com.frejoys.common.dto.admin.StoreResourceLibraryListDto;
import com.frejoys.common.enums.EResourceLibrarySite;
import com.frejoys.common.enums.EResourceStatus;
import com.frejoys.common.response.Result;
import com.frejoys.common.util.RequestUtil;
import com.frejoys.common.vo.admin.AdminResourceLibraryListVo;
import com.frejoys.common.vo.store.ResourceLibraryListVo;
import com.frejoys.service.ResourceLibraryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "资源库", description = "资源库")
@RestController
@RequiredArgsConstructor
@RequestMapping(CommonConstant.routePrefixAdmin)
@Authorization(Authority.Private)
public class AdminResourceLibraryController {

    private final ResourceLibraryService resourceLibraryService;

    @Operation(summary = "查询资源库列表")
    @PostMapping("/resourceLibrary/resourceLibraryListInfo")
    public Result<IPage<AdminResourceLibraryListVo>> resourceLibraryListInfo(@RequestBody @Validated StoreResourceLibraryListDto dto){
        dto.setStatus(EResourceStatus.uploaded.getValue());
        dto.setUserId(RequestUtil.userId());
        return Result.success(resourceLibraryService.adminResourceLibraryListInfo(dto));
    }
}
